/**
 * 
 */
package chatServer;

import java.io.Serializable;

import messenger.Contact;

/**
 * @author (Group 42) William Orem, Joseph Hamilton, Kevin Benik
 * 
 */
public class UserDB extends Contact implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7545404629359923050L;
	private String password;

	/**
	 * @param password
	 * @param user
	 */
	public UserDB(String password, Contact user) {
		super(user.getpId(), user.getFirstName(), user.getLastName(), user
				.getPhone(), user.geteMail(), user.getYear(), user
				.getUserName());
		this.password = password;

	}

	/**
	 * @param pId
	 * @param userName
	 * @param password
	 */
	public UserDB(String pId, String userName, String password) {
		this.pId = pId;
		this.userName = userName;
		this.password = password;
	}

	/**
	 * @param pId
	 * @param firstName
	 * @param lastName
	 * @param phone
	 * @param eMail
	 * @param year
	 * @param userName
	 * @param password
	 */
	public UserDB(String pId, String firstName, String lastName, String phone,
			String eMail, int year, String userName, String password) {
		super(pId, firstName, lastName, phone, eMail, year, userName);
		this.password = password;
	}

	/**
	 * @return the Contact of user
	 */
	public Contact getContact() {

		Contact newContact = new Contact(pId, firstName, lastName, phone,
				eMail, year, userName);
		return newContact;
	}

	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * @return the pId
	 */
	public String getpId() {
		return pId;
	}

	/**
	 * @return the userName
	 */
	public String getUserName() {
		return userName;
	}

	/**
	 * @param password
	 *            the password to set
	 */
	public void setPassword(String password) {
		this.password = password;

	}

	/**
	 * @param pId
	 *            the pId to set
	 */
	public void setpId(String pId) {
		this.pId = pId;
	}

	/**
	 * @param userName
	 *            the userName to set
	 */
	public void setUserName(String userName) {
		this.userName = userName;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		if (userName != null) {
			builder.append(userName);
			builder.append(" ");
		}
		if (pId != null) {
			builder.append(pId);
			builder.append(" ");
		}
		if (firstName != null) {
			builder.append(firstName);
			builder.append(" ");
		}
		if (lastName != null) {
			builder.append(lastName);
			builder.append(" ");
		}
		if (phone != null) {
			builder.append("phone: ");
			builder.append(phone);
			builder.append(" ");
		}
		if (eMail != null) {
			builder.append("eMail: ");
			builder.append(eMail);
			builder.append(" ");
		}
		builder.append("graduation year: ");
		builder.append(year);
		return builder.toString();
	}
}
